package com.intellij.GraphEditor;

import javax.swing.*;
import java.awt.event.MouseListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * Created by IntelliJ IDEA.
 * User: karpov
 * Date: 30.11.2006
 * Time: 1:22:07
 * To change this template use File | Settings | File Templates.
 */
public class PopupListener extends MouseAdapter {
    JPopupMenu popup;
    Editor ed;
    public PopupListener(JPopupMenu popup) {
        this.popup=popup;
        ed = new Editor();
    }
    public void mousePressed(MouseEvent e) {
            maybeShowPopup(e);
        }

        public void mouseReleased(MouseEvent e) {
            maybeShowPopup(e);
        }

        private void maybeShowPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {

                popup.show(e.getComponent(),e.getX(), e.getY());
                ed.repaint_();
            }
        }



}
